package com.xiaomi.service.Impl;

import com.xiaomi.dao.CpfenleiMapper;
import com.xiaomi.dao.ZhongleiMapper;
import com.xiaomi.entity.Cpfenlei;

import com.xiaomi.service.CpfenleiService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
import java.util.Map;

/**
 * @ClassName CpfenleiServicelmpl
 * @Description TODO
 * @Author HP
 * @Date 2021/11/29 1:05
 */
@Service
public class CpfenleiServicelmpl implements CpfenleiService {
    @Resource
    CpfenleiMapper cpfenleiMapper;
    @Resource
    ZhongleiMapper zhongleiMapper;

    @Override
    public List<Cpfenlei> selectAll(Map<String, Object> pars) {
        List<Cpfenlei> cpfenleiList=cpfenleiMapper.selectAll(pars);
        for (Cpfenlei cpfenlei:cpfenleiList){
            cpfenlei.setZhongleiList(zhongleiMapper.selectByZhongleiid(cpfenlei.getId()));
        }
        return cpfenleiList;
    }

    @Override
    public int count(Map<String, Object> pars) {
        return cpfenleiMapper.count(pars);
    }

    @Override
    public int add(Cpfenlei cpfenlei) {
        return cpfenleiMapper.add(cpfenlei);
    }

    @Override
    public int del(int id) {
        return cpfenleiMapper.del(id);
    }

    @Override
    public int update(Cpfenlei cpfenlei) {
        return cpfenleiMapper.update(cpfenlei);
    }
}
